#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

int countWords(const string &str)
{
    int cnt = 0;
    for (int i = 0; i < str.size(); ) {
	while (i < str.size() && str[i] == ' ') i++;
	if (i != str.size()) cnt ++;
	while (i < str.size() && str[i] != ' ') i++;
    }
    return cnt;
}

int main(int argc, char **argv)
{
    cout << countWords("Hangyu is an engineer") << endl;  
    cout << countWords("   Hangyu is an engineer") << endl;  
    cout << countWords("Hangyu is an engineer  ") << endl;  
    cout << countWords("Hangyu is an    engineer") << endl;  
    cout << countWords("") << endl;
}
